home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / Util / C / Cron 1.0d16 Distribution.sit / Cron 1.0d16 Distribution / Example Source / Cron Commons / argc Receiver.h < prev   
Encoding:
C/C++ Source or Header  |  1993-10-14  |  1.5 KB  |  45 lines  |  [TEXT/KAHL]

  1. #ifndef _argc_Receiver_
  2. #define _argc_Receiver_
  3.  
  4.  
  5. #ifdef ReinvokeMain
  6.     
  7.     #define main            mainarg
  8.     
  9.     //    If the argcQuitFlag global is TRUE, we've received a Quit event, 
  10.     //    and the command should abort as gracefully as possible.
  11.     
  12.     extern Boolean            argcQuitFlag;
  13.     
  14.     //    Your "main" procedure will be called by the glue code which 
  15.     //    retrieves the argc/argv arguments whenever a set of arguments 
  16.     //    arrives. Note, however, that your main isn't the *real* main
  17.     //    procedure. The #define above is actually changing the name of
  18.     //    your main procedure to "mainarg" and my glue code is calling 
  19.     //    it as a subroutine.
  20.     //
  21.     //    While this approach solves several problems inherent in the
  22.     //    use of the earlier argcReceiver scheme, it creates one new
  23.     //    challenge for developers: since your main procedure can be
  24.     //    called repeatedly during a single invocation of your program, 
  25.     //    you need to make sure that your code cleans-up behind itself
  26.     //    each time it completes. This means, for instance, that you've 
  27.     //    got to manually reinitialize any globals you may have created. 
  28.     //    Otherwise the values from the previous invocation of your 
  29.     //    "main" procedure will still be lingering in the globals, 
  30.     //    possibly causing your code problems you wouldn't normally 
  31.     //    expect.
  32.     //
  33.     //    If the Mac OS handled processes differently, none of this would 
  34.     //    be necessary, of course. (Sigh.)
  35.     
  36.     extern int                mainarg(int argc, char **argv);
  37.     
  38. #else
  39.     
  40.     void                    argcReceiver(int *argcRcvd, char ***argvRcvd);
  41.     
  42. #endif
  43.  
  44.  
  45. #endif